<?php

/* 品牌 cate */
class NewsModel extends BaseModel
{
    var $table  = 'news';
    var $prikey = 'news_id';
    var $_name  = 'news';
	
    var $_relation = array(
		'belongs_cate' => array(
            'model'         => 'category',
            'type'          => BELONGS_TO,
            'foreign_key'   => 'cate_id',
            'reverse'       => 'has_news',
        ),
	);

        /*
     * 判断名称是否唯一
     */
    function unique($title, $news_id = 0)
    {
        $conditions = "title = '" . $title . "' AND news_id != ".$news_id."";
        return count($this->find(array('conditions' => $conditions))) == 0;
    }
}

?>